﻿/*
 * Rappelz: Endless Odyssey - The first free open source Rappelz server emulator
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rappelz.GameServer.Network;
using Rappelz.GameServer.Network.GameClient;

namespace Rappelz.GameServer
{
    public class RappelzIntf
    {
        public void SendEnterMessage(BaseObject client, BaseObject obj) // 0
        {
            Player p = client as Player;
            Messages.SendEnterMsg(p, (GameObject)obj);
        }

        public void SendLeaveMessage(BaseObject client, BaseObject obj) // 4
        {
            Messages.SendLeaveMsg(client, obj);
        }

//         public void SendForceMoveMessage(BaseObject client, BaseObject obj) // 8
//         {
// 
//         }
// 
        public void SendMoveMessage(BaseObject client, BaseObject obj) // 0c
        {
            Messages.SendMoveMsg(client, obj);
        }

        public void SendMoveAckMessage(BaseObject client, uint tm, byte speed) // 10
        {
            Player player = client as Player;
            if(player == null)
                return;
            PacketOut pak = new PacketOut((ushort)ClientOutPackets.MoveAck);
            pak.WriteUInt32(tm);
            pak.WriteByte(speed);
            player.Connection.SendTCP(pak);
        }

        public void SendRegionAckMessage(BaseObject client, uint rx, uint ry) // 14
        {
            Player player = client as Player;
            if(player == null)
                return;
            PacketOut pak = new PacketOut((ushort)ClientOutPackets.RegionAck);
            pak.WriteUInt32(rx);
            pak.WriteUInt32(ry);
            player.Connection.SendTCP(pak);
        }

        public void SendGameMessage(BaseObject client, PacketOut msg) // 18
        {
            Player player = client as Player;
            if(player == null)
                return;
            player.Connection.SendTCP(msg);
        }

        public bool onSetMove(BaseObject pObj, ArPosition oldPos, ArPosition newPos) // 1c
        {
            GameObject obj = GameObject.raw_get(pObj.m_hHandle);
            if (obj != null)
            {
                uint h = pObj.m_hHandle & 0xE0000000;
                if ((int)h == -2147483648 || h == 1073741824 || (int)h == -1073741824 )
                {
                    Creature c = obj as Creature;
                    if (!Creature.QuadTreeItem.IsCanAdd(newPos.x, newPos.y))
                        return false;
                    c.quadTreeItem.RemoveMe();
                    c.quadTreeItem.AddMe();
                }
            }
            return true;
        }
        // Function       :   public void ArcadiaIntf::onNearRegion(BaseObject client, BaseObject obj) // 20
// Function       :   public void ArcadiaIntf(const struct ArcadiaIntf &)
// Function       :   public void ArcadiaIntf()
// Function       :   public struct ArcadiaIntf & operator=(const struct ArcadiaIntf &)

    }
}
